//==============================================================================
//
// Title:       TxAndFbClosedLoop.c
// Purpose:     A short description of the implementation.
//
// Created on:  2013-3-1 at 15:00:35 by Vinson.Zhang
// Copyright:   dafda. All Rights Reserved.
//
//==============================================================================

#include "RFBB.h"         
#include <utility.h>
#include <formatio.h>
#include "stdio.h" 
//for test
#include "rsnrpz.h"
#include "PowerMeter.h"
#include "USB6501.h"
#include "ReadCalXmlFile.h"


_DAQMX_WRITE_PORT_CMD g_szTXFBWritePort1Cmd[4] = {{"SFP_ON","DIO1/port1",TX1TOFB1LOOP},      
												  {"SFP_OFF","DIO1/port1",TX2TOFB2LOOP},
												  {"SFP_OFF","DIO1/port1",TX3TOFB3LOOP},
												  {"SFP_OFF","DIO1/port1",TX4TOFB4LOOP}};


//FMON_ACTION_SYNTHESIZER                              
_SHMON_TX_AND_FB_CLOSED_LOOP_INIT_CMD g_szShmonTxAndFbClosedLoopInitCmd[4] ={
        {"\n" ,"TX_and_FB_Closed_Loop_Inital_Pipe1.txt"},
        {"\n" ,"TX_and_FB_Closed_Loop_Inital_Pipe2.txt"},
        {"\n" ,"TX_and_FB_Closed_Loop_Inital_Pipe3.txt"},
        {"\n" ,"TX_and_FB_Closed_Loop_Inital_Pipe4.txt"}};

_SHMON_TX_AND_FB_CLOSED_LOOP_CMD g_szShmonTxAndFbClosedLoopCmd[12] = {
    	{"\n" ,"TX_and_FB_Closed_Loop_H_Pipe1.txt","dapd -sg 1 -30","ac -I 1" ,"ac -D 1","ac -D 2",0.0,0.0,0.0},
        {"\n" ,"TX_and_FB_Closed_Loop_M_Pipe1.txt","dapd -sg 1 -30","ac -I 1" ,"ac -D 1","ac -D 2",0.0,0.0,0.0},
        {"\n" ,"TX_and_FB_Closed_Loop_L_Pipe1.txt","dapd -sg 1 -30","ac -I 1" ,"ac -D 1","ac -D 2",0.0,0.0,0.0},
        {"\n" ,"TX_and_FB_Closed_Loop_H_Pipe2.txt","dapd -sg 2 -30","ac -I 9" ,"ac -D 9","ac -D 4",0.0,0.0,0.0},
        {"\n" ,"TX_and_FB_Closed_Loop_M_Pipe2.txt","dapd -sg 2 -30","ac -I 9" ,"ac -D 9","ac -D 4",0.0,0.0,0.0},
        {"\n" ,"TX_and_FB_Closed_Loop_L_Pipe2.txt","dapd -sg 2 -30","ac -I 9" ,"ac -D 9","ac -D 4",0.0,0.0,0.0},
        {"\n" ,"TX_and_FB_Closed_Loop_H_Pipe3.txt","dapd -sg 3 -30","ac -I 17","ac -D 17","ac -D 6",0.0,0.0,0.0},
        {"\n" ,"TX_and_FB_Closed_Loop_M_Pipe3.txt","dapd -sg 3 -30","ac -I 17","ac -D 17","ac -D 6",0.0,0.0,0.0},
        {"\n" ,"TX_and_FB_Closed_Loop_L_Pipe3.txt","dapd -sg 3 -30","ac -I 17","ac -D 17","ac -D 6",0.0,0.0,0.0},
        {"\n" ,"TX_and_FB_Closed_Loop_H_Pipe4.txt","dapd -sg 4 -30","ac -I 25","ac -D 25","ac -D 8",0.0,0.0,0.0},
        {"\n" ,"TX_and_FB_Closed_Loop_M_Pipe4.txt","dapd -sg 4 -30","ac -I 25","ac -D 25","ac -D 8",0.0,0.0,0.0},
        {"\n" ,"TX_and_FB_Closed_Loop_L_Pipe4.txt","dapd -sg 4 -30","ac -I 25","ac -D 25","ac -D 8",0.0,0.0,0.0}};

/**************************************************************************************************
  Function:        TxAndFbClosedLoop Initial
  Description:     This test is the Initial of all Pipes.
  Calls:           none
  Called By:       dll
  Table Accessed:  none
  Table Updated:   none
  Input:           none
  Output:          error code
  Return:          none
  Test Case ID:    FRHD_TxAndFbClosedLoop Initial
  Used Command:    g_szShmonTxAndFbClosedLoopInitCmd
**************************************************************************************************/
void __decldllexp TX_TEST TxAndFbClosedLoopInit(tTestData *testData, tTestError *testError)
{

    ErrMsg errMsg = {'\0'};
    ERRORINFO errorInfo;   
    ErrMsg szLogMsg;
    CAObjHandle hStepName = 0;
    char* pszStepName = NULL;
	char* SCRIPT_FILE_PATH = NULL;	//add by Vinson
	
    char kszShmonAgent[BUFFER_SIZE_256] ={'\0'};   
    char szElementPath[BUFFER_SIZE_256] ={'\0'};
    double dTestNum = 0.0;
	//

    int  error = 0;
    int  iPassFail = 0;
    int i = 0;
    int iPipeNum = 0;
    int iReturn = 0;
     char szOutputMessage[BUFFER_SIZE_256] = {'\0'};
	 char  szTemp[512] = {'\0'};
    //////////////////////////////////////////////////////////////////////////   
    // Resolve StepName 
    tsErrChk(TS_SeqContextGetProperty (testData->seqContextCVI, &errorInfo, 
                                       TS_SeqContextStep, CAVT_OBJHANDLE, 
                                       &hStepName));
    tsErrChk(TS_StepGetProperty (hStepName, &errorInfo, TS_StepName, CAVT_CSTRING, 
                                 &pszStepName));

    sprintf( szLogMsg, TEST_NAME_EVENT_FMTSTR, pszStepName );
    ErrChk( EELog_INEventLogLogEvent( g_hEventLog, NULL, szLogMsg ) );

    // Post message to GUI
    tsErrChk(TS_ThreadPostUIMessageEx (g_hThreadPostUIMessage, NULL,
                                       TS_UIMsg_ProgressText, 0.0,
                                       pszStepName, 0, VTRUE));

    //--------------------------------------------------------------------
    // Get Test Parameters from Sequence FileGlobals    
    sprintf(szElementPath, "%s.%s.PARAMETERS.TestNum", TESTPLAN_BASE_PATH, pszStepName );   
    tsErrChk(TS_PropertyGetValNumber(testData->seqContextCVI, &errorInfo, szElementPath, 0, &dTestNum));
	
	//Get SCRIPT_FILE_PATH from TestPlan Head    
    sprintf( szElementPath, "%s.PARAMETERS.SCRIPT_FILE_PATH", TESTPLAN_BASE_PATH_EXT );
    tsErrChk(TS_PropertyGetValString (testData->seqContextCVI, &errorInfo, szElementPath, 0, &SCRIPT_FILE_PATH));
	//---------------------------------------------------------------------
	
    if((dTestNum >= 0) && (dTestNum < 4))
    {
        i = dTestNum;
    }

    //--------------------------------------------------------------------
    sprintf( szLogMsg, "##### Connect the TX_FB%d cable #####",i);
    ErrChk(EELog_INEventLogLogEvent (g_hEventLog, NULL, szLogMsg));
       
    // TX and FB switch by 6501
	ErrChk(USBWriteDigToPort(g_szTXFBWritePort1Cmd[i].ucTashName,g_szTXFBWritePort1Cmd[i].ucDevport,g_szTXFBWritePort1Cmd[i].uiWriteData));
   
		
	//Fulfill Struct
	sprintf(kszShmonAgent, "%s\\%s", SCRIPT_FILE_PATH, g_szShmonTxAndFbClosedLoopInitCmd[i].cRemoteFileName);

	strcpy(g_szShmonTxAndFbClosedLoopInitCmd[i].cLocalFilePath, kszShmonAgent);
	
	
	//FTP upload script files 
    
	iReturn = RfbbInetFTPAutoSend(g_szDUTIP, "", "", g_szShmonTxAndFbClosedLoopInitCmd[i].cLocalFilePath, g_szShmonTxAndFbClosedLoopInitCmd[i].cRemoteFileName, INET_FTP_FILE_TYPE_BINARY);    
    if(iReturn < 0)
    	{
        sprintf( szLogMsg, STRING_MESSAGE_Ftp_File_Err, g_szDUTIP, InetGetErrorMessage( iReturn ) );
        EELog_INEventLogLogEvent (g_hEventLog, NULL, szLogMsg);
        
        goto Error;
    	} 

	//InetTelnetOpen(ShellCommand) 
    g_hShellCommand = RfbbInetTelnetOpen (g_szDUTIP, g_iShellCommandPort, 0); 

    //run script    
    sprintf(kszShmonAgent,". %s",g_szShmonTxAndFbClosedLoopInitCmd[i].cRemoteFileName);
    Shmon_RunScript(kszShmonAgent,5);
    
//    sprintf(szOutputMessage,"please connect the TX and FB RF-cable on Pipe%d",(i + 1));
//    MessagePopup("Tx And Fb Closed Loop Test", szOutputMessage);
Error:
    
#if(ON_OFF != SIMU_VERS) 
    
    if(error <0 )
    	{
        testData->result = FAIL;
    	}
    else 
    	{
        testData->result = PASS;
    	}

	//InetTelnetClose(ShellCommand)
    InetTelnetClose(g_hShellCommand);
	
    // FREE RESOURCES
    CA_DISCARD_OBJ( hStepName );
    CA_FREE( pszStepName );
	CA_FREE( SCRIPT_FILE_PATH ); 

    // If an error occurred, set the error flag to cause a run-time error in TestStand.
    if(error < 0)
    	{
        testError->errorFlag = TRUE;
        testError->errorCode = error;
        testData->replaceStringFuncPtr(&testError->errorMessage, errMsg);
    	}
#else
    testData->result = PASS;
#endif

   // Clear message from GUI
   TS_ThreadPostUIMessageEx (g_hThreadPostUIMessage, NULL,
                                 TS_UIMsg_ProgressText, 0.0, " ", 0, VTRUE);

   return;    
}
/**************************************************************************************************
  Function:        TxAndFbClosedLoop
  Description:     This test is the tests of TxAndFbClosedLoop for all Pipes.
  Calls:           none
  Called By:       dll
  Table Accessed:  none
  Table Updated:   none
  Input:           none
  Output:          error code
  Return:          none
  Test Case ID:    FRHD_TxAndFbClosedLoop
  Used Formula:    FbPow = TxPow - FBPathLoss 
  					FbGain = PDRX power - FbPow
  					RxTopiGain = 10 * log10((AdcPow+ 1) / ( CorrectFact * CorrectFact / 8)) + 6 - FbPow
  					vvaRange =  Maximum TxOutputPow - Minimum TxOutputPow

**************************************************************************************************/

void __decldllexp TX_TEST TxAndFbClosedLoop(tTestData *testData, tTestError *testError)
{

    ErrMsg errMsg = {'\0'};
    ERRORINFO errorInfo;   
    ErrMsg szLogMsg;
    CAObjHandle hStepName = 0;
    ViStatus viStatus; // For nrpErrChk -macro
    TSObj_Property stepNumericArrayHandle = 0;
    char* pszStepName = NULL;
	char* SCRIPT_FILE_PATH = NULL;	//add by Vinson 
    char kszShmonAgent[BUFFER_SIZE_256] ={'\0'};   
    char szElementPath[BUFFER_SIZE_256] ={'\0'};
    double dTestNum = 0.0;    
    double dRxGain = 0.0;
    double dFbGain = 0.0;
    double dFbInputPow = 0.0;
	
	//wendy add below three var
	double dFrequency =0.0;
	double dPWMPathLoss =0.0;
	double dFBPathLoss =0.0;
	
	//Vinson add var for vva test
	double dvvaRange = 0.0;
	
	char  szTemp[512] = {'\0'};
	
    float dTxPMOffset = 0.0;
    float dTxFbOffset = 0.0;     
    double dOutputInDbm = 0.0;// for test
    double dTxOutputPow = 0.0;
    int  error = 0;
    int  iPassFail = 0;
    int i = 0;
    int iPipeNum = 0;
    int iReturn = 0;
    
    //////////////////////////////////////////////////////////////////////////   
    // Resolve StepName 
    tsErrChk(TS_SeqContextGetProperty (testData->seqContextCVI, &errorInfo, 
                                       TS_SeqContextStep, CAVT_OBJHANDLE, 
                                       &hStepName));
    tsErrChk(TS_StepGetProperty (hStepName, &errorInfo, TS_StepName, CAVT_CSTRING, 
                                 &pszStepName));

    sprintf( szLogMsg, TEST_NAME_EVENT_FMTSTR, pszStepName );
    ErrChk( EELog_INEventLogLogEvent( g_hEventLog, NULL, szLogMsg ) );

    // Post message to GUI
    tsErrChk(TS_ThreadPostUIMessageEx (g_hThreadPostUIMessage, NULL,
                                       TS_UIMsg_ProgressText, 0.0,
                                       pszStepName, 0, VTRUE));
    
    TS_PropertyGetPropertyObject(testData->seqContextCVI, &errorInfo,"Step.NumericArray", 0, 
                                        &stepNumericArrayHandle );

    //--------------------------------------------------------------------
    // Get Test Parameters from Sequence FileGlobals    
    sprintf(szElementPath, "%s.%s.PARAMETERS.TestNum", TESTPLAN_BASE_PATH, pszStepName );   
    tsErrChk(TS_PropertyGetValNumber(testData->seqContextCVI, &errorInfo, szElementPath, 0, &dTestNum));
	 //wendy add below to input dFrequency from test plan
	
    sprintf(szElementPath, "%s.%s.PARAMETERS.TxFrequency", TESTPLAN_BASE_PATH, pszStepName );   
    tsErrChk(TS_PropertyGetValNumber(testData->seqContextCVI, &errorInfo, szElementPath, 0, &dFrequency));
	
	//Get SCRIPT_FILE_PATH from TestPlan Head    
    sprintf( szElementPath, "%s.PARAMETERS.SCRIPT_FILE_PATH", TESTPLAN_BASE_PATH_EXT );
    tsErrChk(TS_PropertyGetValString (testData->seqContextCVI, &errorInfo, szElementPath, 0, &SCRIPT_FILE_PATH));
	
	// Get oFFSET from Sequence FileGlobals (Old style) 
    //sprintf(szElementPath, "%s.%s.PARAMETERS.TxPMOffset", TESTPLAN_BASE_PATH, pszStepName );   
    //tsErrChk( TS_PropertyGetValFloat( testData->seqContextCVI, &errorInfo, szElementPath, 0, &dTxPMOffset) );

    //sprintf(szElementPath, "%s.%s.PARAMETERS.TxFbOffset", TESTPLAN_BASE_PATH, pszStepName );   																			
    //tsErrChk( TS_PropertyGetValFloat( testData->seqContextCVI, &errorInfo, szElementPath, 0, &dTxFbOffset) );
	//---------------------------------------------------------------------
	
    if((dTestNum >= 0) && (dTestNum < 12))
    	{
        i = dTestNum;
    	}
    
    //Fulfill Struct
	sprintf(kszShmonAgent, "%s\\%s", SCRIPT_FILE_PATH, g_szShmonTxAndFbClosedLoopCmd[i].cRemoteFileName);
	strcpy(g_szShmonTxAndFbClosedLoopCmd[i].cLocalFilePath, kszShmonAgent);
	
	//FTP upload script files  
    iReturn = RfbbInetFTPAutoSend(g_szDUTIP, "", "", g_szShmonTxAndFbClosedLoopCmd[i].cLocalFilePath, g_szShmonTxAndFbClosedLoopCmd[i].cRemoteFileName, INET_FTP_FILE_TYPE_BINARY);    
    
	if(iReturn < 0)
    	{
        sprintf( szLogMsg, STRING_MESSAGE_Ftp_File_Err, g_szDUTIP, InetGetErrorMessage( iReturn ) );
        EELog_INEventLogLogEvent (g_hEventLog, NULL, szLogMsg);
        
        goto Error;
    	} 

	//InetTelnetOpen(ShellCommand) 
    g_hShellCommand = RfbbInetTelnetOpen (g_szDUTIP, g_iShellCommandPort, 0); 

    //run script    
    sprintf(kszShmonAgent,". %s",g_szShmonTxAndFbClosedLoopCmd[i].cRemoteFileName);
    Shmon_RunScript(kszShmonAgent,10);
    
    //Delay(2);
	
	iPipeNum = i / 3;
	sprintf(szTemp ,"TX%d_PWM", iPipeNum+1);
	
	//Check g_hCalFileParser, Cal file, ActivX  by Vinson
	if(g_hCalFileParser == 0)
		{
		sprintf(szLogMsg, "Error: g_hCalFileParser= %d, Please check TI Sequence",g_hCalFileParser);  
        EELog_INEventLogLogEvent (g_hEventLog, NULL, szLogMsg);
		}
	
	//Read Cal file
	ErrChk(CALFILEPARSERLib_IICalFileParserGetCalValue (g_hCalFileParser, NULL, 
														szTemp, dFrequency, &dPWMPathLoss));
	
	   
	sprintf(szTemp ,"TX%d_FB", iPipeNum+1);
	ErrChk(CALFILEPARSERLib_IICalFileParserGetCalValue (g_hCalFileParser, NULL, 
														szTemp, dFrequency, &dFBPathLoss));
	
    /********************read power  from meter ***************************/
    // Setup PowerMeter offset and frequency
    nrpErrChk( rsnrpz_corr_setOffset(g_hPowerMeter, 1, dPWMPathLoss ));
		
    nrpErrChk( rsnrpz_chan_setCorrectionFrequency( g_hPowerMeter, 1, dFrequency*1000000 ) );
		
    error = MeasurePower( 1, 1, 0.2, &dOutputInDbm );
    if( error  < 0 )
    	{
       sprintf(errMsg, "Error: MeasurePower failed!");
       ErrChk( EELog_INEventLogLogEvent (g_hEventLog, NULL, errMsg) ); 
       goto Error;
    	}

    sprintf(szLogMsg,"%s power is %f dBm",g_szShmonTxAndFbClosedLoopCmd[i].cRemoteFileName,dOutputInDbm)   ;
    ErrChk( EELog_INEventLogLogEvent( g_hEventLog, NULL, szLogMsg ) );
    
    /********************read power from DAPD ***************************/
    //send shell command and compare return value 
  	//iPipeNum = i / 3;
    sprintf(kszShmonAgent,"dapd -stat %d",(iPipeNum + 1));
    ErrChk(ShellCommand_Numeric(kszShmonAgent, -1,"PDRX power............ ",&g_szShmonTxAndFbClosedLoopCmd[i].dGetFbValue)); 
    sprintf( szLogMsg, "the PDRX power is %f" ,g_szShmonTxAndFbClosedLoopCmd[i].dGetFbValue);
    EELog_INEventLogLogEvent (g_hEventLog, NULL, szLogMsg);
	

    sprintf(kszShmonAgent,"fpga -MERA%d -r 0x18006",(iPipeNum + 1));
    ErrChk(ShellCommand_HexNumeric(kszShmonAgent, -1,"Read ",&g_szShmonTxAndFbClosedLoopCmd[i].dGetAdcPow));

    sprintf(kszShmonAgent,"fpga -MERA%d -r 0x1A040",(iPipeNum + 1));
    ErrChk(ShellCommand_HexNumeric(kszShmonAgent, -1,"Read ",&g_szShmonTxAndFbClosedLoopCmd[i].dGetCorrectFact));
    
  	//  dTxOutputPow = dOutputInDbm (CalData offseted);    
	dTxOutputPow = dOutputInDbm;
	
	//  FbPow = TxPow - FBPathLoss
	dFbInputPow = dTxOutputPow - dFBPathLoss;
    
	//  FbGain = PDRX power - FbPow
    dFbGain = g_szShmonTxAndFbClosedLoopCmd[i].dGetFbValue - dFbInputPow;
	
	//	RxTopiGain = 10 * log10((AdcPow+ 1) / ( CorrectFact * CorrectFact / 8)) + 6 - FbPow 
	dRxGain = 10 * log10((g_szShmonTxAndFbClosedLoopCmd[i].dGetAdcPow+  1) / ((g_szShmonTxAndFbClosedLoopCmd[i].dGetCorrectFact * g_szShmonTxAndFbClosedLoopCmd[i].dGetCorrectFact) / 8)) + 6 - dFbInputPow;
    sprintf( szLogMsg, "Topi + Rx Gain is %f" ,dRxGain);
	EELog_INEventLogLogEvent (g_hEventLog, NULL, szLogMsg);
	
	// get vva range
	sprintf(kszShmonAgent,"dapd -vva %d 0x0000",(iPipeNum + 1));
	ErrChk(ShellCommand_Action(kszShmonAgent, 2));
    error = MeasurePower( 1, 1, 0.2, &dOutputInDbm );
    if( error  < 0 )
    	{
       sprintf(errMsg, "Error: MeasurePower failed!");
       ErrChk( EELog_INEventLogLogEvent (g_hEventLog, NULL, errMsg) ); 
       goto Error;
    	}

    sprintf(szLogMsg,"%s Max power is %f dBm",g_szShmonTxAndFbClosedLoopCmd[i].cRemoteFileName,dOutputInDbm)   ;
    ErrChk( EELog_INEventLogLogEvent( g_hEventLog, NULL, szLogMsg ) );
	
	dvvaRange = dOutputInDbm;
	
	sprintf(kszShmonAgent,"dapd -vva %d 0x3FFF",(iPipeNum + 1));
	ErrChk(ShellCommand_Action(kszShmonAgent, 2)); 
    error = MeasurePower( 1, 1, 0.2, &dOutputInDbm );
    if( error  < 0 )
    	{
       sprintf(errMsg, "Error: MeasurePower failed!");
       ErrChk( EELog_INEventLogLogEvent (g_hEventLog, NULL, errMsg) ); 
       goto Error;
    	}

    sprintf(szLogMsg,"%s Min power is %f dBm",g_szShmonTxAndFbClosedLoopCmd[i].cRemoteFileName,dOutputInDbm)   ;
    ErrChk( EELog_INEventLogLogEvent( g_hEventLog, NULL, szLogMsg ) );
	
	//vvaRange =  Maximum TxOutputPow - Minimum TxOutputPow
	dvvaRange = dvvaRange - dOutputInDbm;
	
    sprintf(szLogMsg,"%s vva range is %f dBm",g_szShmonTxAndFbClosedLoopCmd[i].cRemoteFileName,dvvaRange)   ;
    ErrChk( EELog_INEventLogLogEvent( g_hEventLog, NULL, szLogMsg ) );
    // get vva range end Vinson

Error:

    //inactive Carry
    sprintf(kszShmonAgent,g_szShmonTxAndFbClosedLoopCmd[i].cSetDapd);
    ShellCommand_String(kszShmonAgent, -1,"successfully", &iPassFail);
    
    sprintf(kszShmonAgent,g_szShmonTxAndFbClosedLoopCmd[i].cInactiveTxCarry);
    ShellCommand_String(kszShmonAgent, -1,"StatusOk", &iPassFail);
	
	sprintf(kszShmonAgent,g_szShmonTxAndFbClosedLoopCmd[i].cDeleteTxCarry);
	Shmon_RunCmdNoAck(kszShmonAgent,2);

	sprintf(kszShmonAgent,g_szShmonTxAndFbClosedLoopCmd[i].cDeleteRxCarry);
	Shmon_RunCmdNoAck(kszShmonAgent,2);
#if(ON_OFF != SIMU_VERS) 

    if(iPassFail == 1)
    	{
        testData->result = PASS;
    	}
    else 
    	{
        testData->result = FAIL;
    	}
    TS_PropertySetValNumberByOffset( stepNumericArrayHandle, &errorInfo,0, 0,dTxOutputPow);
    TS_PropertySetValNumberByOffset( stepNumericArrayHandle, &errorInfo,1, 0,dFbGain);
    TS_PropertySetValNumberByOffset( stepNumericArrayHandle, &errorInfo,2, 0,dRxGain);
	
	// return vva range 
	TS_PropertySetValNumberByOffset( stepNumericArrayHandle, &errorInfo,3, 0,dvvaRange);        
    
	//InetTelnetClose(ShellCommand) 
    InetTelnetClose(g_hShellCommand);
	
    // FREE RESOURCES
    CA_DISCARD_OBJ( hStepName );
	CA_DISCARD_OBJ( stepNumericArrayHandle );
    CA_FREE( pszStepName );
	CA_FREE( SCRIPT_FILE_PATH );

    // If an error occurred, set the error flag to cause a run-time error in TestStand.
    if(error < 0)
    	{
        testError->errorFlag = TRUE;
        testError->errorCode = error;
        testData->replaceStringFuncPtr(&testError->errorMessage, errMsg);
    	}
#else
    testData->result = PASS;
#endif

   // Clear message from GUI
   TS_ThreadPostUIMessageEx (g_hThreadPostUIMessage, NULL,
                                 TS_UIMsg_ProgressText, 0.0, " ", 0, VTRUE);

   return;    
}

